<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>修改私海</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="../../css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<div class="layui-form layuimini-form">

    <input type="text" name="privateSeasId" disabled id="sid" value="" style="display:none" class="layui-input">
    <input type="text" name="selectedStatusName" disabled id="selectedStatusName" style="display:none" value="" class="layui-input">

    <div class="layui-form-item">
        <label class="layui-form-label">微信号</label>
        <div class="layui-input-block">
            <input type="text" name="wechatNo" id ="wechatNo" placeholder="请输入微信号" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">备注</label>
        <div class="layui-input-block">
            <input type="text" name="remark" id = "remark"  placeholder="请输入备注" value="" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">状态</label>
        <div class="layui-input-block">
            <select name="status" lay-filter="aihao" id="status">
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认</button>
        </div>
    </div>
</div>

<script src="../../lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form'], function () {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.$;

        $.ajax({
            type: "get",
            url: "/zxjy/enum/privateseasstatus",
            // url: '../../api/status.json',
            headers: {
                'Authorization': layui.data("Authorization")['Authorization'],
            },
            success: function (result) {
                if (result.state === 200) {
                    for (obj of result.result) {
                        if (obj.value === $("#selectedStatusName").val()){
                            $("#status").append("<option value=\"" + obj.key + "\" selected  =  \"selected\">" + obj.value + "</option>");
                        }else {
                            $("#status").append("<option value=\"" + obj.key + "\">" + obj.value + "</option>");
                        }
                    }
                    //重新渲染
                    layui.form.render("select");
                }
            }
        });

        //监听提交
        form.on('submit(saveBtn)', function (data) {
            $.ajax({
                type: "POST",
                url: "/zxjy/privateseas/upd/employee",
                contentType: "application/json; charset=utf-8",
                data: JSON.stringify(data.field),
                headers: {
                    'Authorization': layui.data("Authorization")['Authorization'],
                },
                success: function (result) {
                    if (result.state === 200) {
                        parent.layui.table.reload("currentTableId");
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index); //再执行关闭
                    }
                }
            });

        });

    });
</script>
</body>
</html>
